package kz.edu.sdu.itech.pcs.server;

import java.util.Scanner;

import kz.edu.sdu.itech.pcs.common.Message;

public class MessageFromMonitor extends Message {
   Monitor monitor;

   public MessageFromMonitor(Monitor worker) {
      this.monitor = worker;
   }

   public boolean read() {
      boolean ok = true;
      try {
         String raw = monitor.in.nextLine();
         String line = (new Scanner(raw)).findInLine(REQUEST_PATTERN);
         if (AppProps.DEBUG)
            Monitor.log.debug(String.format("read from %s: %s", monitor.getSomeName(), line));
         ok = read(line);
      } catch (Exception e) {
         ok = false;
      }
      return ok;
   }

}
